import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-11-07
 * Time: 12:52
 */

public class MyEasyHash {
    int[] array = {1,7,6,4,5,9}; // 数据集就
    int[] hashArray = new int[10]; //哈希表

    //哈希函数
    public int hash(int key){
        return key % hashArray.length;
        //这样的算术关系 指定简单的哈希函数
    }

    //像哈希表中 存储数据
    public void deposit(int[] array){
        int index = 0;
        for (int i = 0; i < array.length; i++) {
            index = hash(array[i]); //哈希函数 算出对应哈希的key值
            hashArray[index] = array[i]; // 将数据value值存入对应的key值当中
        }
    }


    public static void main(String[] args) {
        MyEasyHash hash = new MyEasyHash();
        hash.deposit(hash.array);
        System.out.println(Arrays.toString(hash.hashArray));
        System.out.println(1%6); //1
    }
}
